from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import get_game

class river5(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
           
        # build list of actions
        self.add_action(Out)
        self.add_action(Down)
        self.add_action(Fish)
    
    # return description of room.
    def get_description(self):
        return "You feel you are getting close to the end of this damn river, but you are also getting pretty hungry."
    
    # return image of room
    def get_image(self):
        return 'river2.jpg'

    def is_fish(self):
        
        game = get_game()
        player = game.get_player()
        if 'hook and string' in player.inventory:
            return True
        else:
        # if not, return this
            return False

class River5Handler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return river5

# define actions for this room

class Out(Action):
    def __init__(self):
        Action.__init__(self, "Out")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Walk toward the Lodge"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'river4'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"


class Down(Action):
    def __init__(self):
        Action.__init__(self, "Down")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Continue along the river path"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'victory_room'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class Fish(Action):
    def __init__(self):
        Action.__init__(self, "Fish")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Fish"
    
    def is_enabled(self):
        if self.room.is_fish():
            return True
        else:
            return False
        
    def get_destination(self):
        return 'death'
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    